// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: chensili

#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include "appcoin2/support/symbology/py_product.h"

namespace py = pybind11;

namespace appcoin2::support::symbology {

void AddPySymbology(py::module* m) {
  py::class_<PyCurrency>(*m, "PyCurrency")
      .def_property_readonly("exchange_name", &PyCurrency::exchange_name)
      .def_property_readonly("symbol", &PyCurrency::symbol)
      .def_property_readonly("native_symbol", &PyCurrency::native_symbol)
      .def_property_readonly("currency", &PyCurrency::currency)
      .def_property_readonly("native_currency", &PyCurrency::native_currency)
      .def_property_readonly("feed_currency", &PyCurrency::feed_currency)
      .def_property_readonly("order_currency", &PyCurrency::order_currency);


  py::class_<PyProduct>(*m, "PyProduct")
      .def_static("from_norm", &PyProduct::from_norm)
      .def_static("from_native", &PyProduct::from_native)
      .def_property_readonly("product_holder",
                             &PyProduct::product_holder)
      .def_property_readonly("market_name", &PyProduct::market_name)
      .def_property_readonly("exchange_name", &PyProduct::exchange_name)
      .def_property_readonly("symbol", &PyProduct::symbol)
      .def_property_readonly("native_symbol", &PyProduct::native_symbol)
      .def_property_readonly("feed_native_symbol", &PyProduct::feed_native_symbol)
      .def_property_readonly("order_native_symbol", &PyProduct::order_native_symbol)
      .def_property_readonly("relative_norm", &PyProduct::relative_norm)
      .def_property_readonly("absolute_norm", &PyProduct::absolute_norm)
      .def_property_readonly("subscription_symbol", &PyProduct::subscription_symbol)
      .def_property_readonly("native_subscription_symbol", &PyProduct::native_subscription_symbol)
      .def_property_readonly("base", &PyProduct::base)
      .def_property_readonly("quote", &PyProduct::quote)
      .def_property_readonly("exchange", &PyProduct::exchange)
      .def_property_readonly("product_type", &PyProduct::product_type)
      .def_property_readonly("short_symbol", &PyProduct::short_symbol)
      .def_property_readonly("full_symbol", &PyProduct::full_symbol)
      .def_property_readonly("contract_type", &PyProduct::contract_type)
      .def_property_readonly("expiry_str", &PyProduct::expiry_str)
      .def_property_readonly("is_perpetual", &PyProduct::is_perpetual)
      .def_property_readonly("is_immediate", &PyProduct::is_immediate)
      .def_property_readonly("strike_price", &PyProduct::strike_price)
      .def_property_readonly("strike_price_multiplier", &PyProduct::strike_price_multiplier)
      .def_property_readonly("option_side", &PyProduct::option_side)
      .def("search_product_holder",
           &PyProduct::search_product_holder,
           py::return_value_policy::move);

  py::class_<PyProductInfo>(*m, "PyProductInfo")
      .def_property_readonly("is_inverse", &PyProductInfo::is_inverse)
      .def_property_readonly("contract_value", &PyProductInfo::contract_value)
      .def_property_readonly("taker_fee_rate", &PyProductInfo::taker_fee_rate)
      .def_property_readonly("maker_fee_rate", &PyProductInfo::maker_fee_rate)
      .def_property_readonly("min_amount", &PyProductInfo::min_amount)
      .def("round_down", &PyProductInfo::round_down)
      .def("round_up", &PyProductInfo::round_up)
      .def_property_readonly("first_tick_size", &PyProductInfo::first_tick_size)
      .def_property_readonly("min_qty", &PyProductInfo::min_qty)
      .def_property_readonly("asset", &PyProductInfo::asset)
      .def_property_readonly("asset_multiplier", &PyProductInfo::asset_multiplier)
      .def_property_readonly("DebugString", &PyProductInfo::DebugString);

  py::class_<PyProductHolder>(*m, "PyProductHolder")
      .def_property_readonly("product_info", &PyProductHolder::product_info);
}

PYBIND11_MODULE(py_symbology, m) { AddPySymbology(&m); };
}  // namespace appcoin2::support::symbology
